home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / zbpc_460.zip / UTILITY.EXE / STRINPUT.BAS < prev    next >
BASIC Source File  |  1991-03-27  |  3KB  |  90 lines

  1. Length%=40   'Length of input field
  2. XOrigin%=10  'Column position to accept input
  3. YOrigin%=10  'Row position to accept input
  4. InputMask$=STRING$(Length%,32) 'Initialize input string to --- try 177
  5. Mask$=CHR$(32) 'Filler for backspace, should be the same value as above
  6.  
  7. Position%=1  'Position in the field to begin the edit, usually the left
  8. Insert%=1    'Toggles start-up state of insert, 1 is insert on, 6 is off
  9.  
  10. COLOR,31:CLS
  11. PRINT@(XOrigin%,YOrigin%)InputMask$;
  12.  
  13. "CheckKey"    'Look for input, report in KeyValue$
  14. LOCATEXOrigin%+Position%-1,YOrigin%,1,Insert%,7
  15. KeyValue$=INKEY$
  16. IFKeyValue$=""GOTO"CheckKey"
  17.  
  18. Code$=""      'Determine if regular or special key input
  19. IFLEN(KeyValue$)=2Code$=RIGHT$(KeyValue$,1)
  20.  
  21. LONGIF Code$=""   'Process regular keys
  22.   LONGIFKeyValue$=CHR$(8)  'handle backspace
  23.     MID$(InputMask$,Position%,1)=Mask$
  24.     IFPosition%>1Position%=Position%-1
  25.   ENDIF
  26.  
  27.               'Terminate input routine with ENTER key and return Result$
  28.   IFKeyValue$=CHR$(13)Result$=InputMask$:END
  29.  
  30.               'Overwrite old information, change to 48 and 57 to
  31.               'to restrict input to numeric
  32.   LONGIFASC(KeyValue$)>31ANDASC(KeyValue$)<127ANDInsert%=6
  33.     MID$(InputMask$,Position%,1)=KeyValue$:Position%=Position%+1
  34.     IFPosition%>Length%Position%=Position%-1
  35.   ENDIF
  36.  
  37.               'Insert information, change to 48 and 57 to
  38.               'to restrict input to numeric
  39.   LONGIFASC(KeyValue$)>31ANDASC(KeyValue$)<127ANDInsert%=1
  40.     Temp$=RIGHT$(InputMask$,Length%-Position%+1):X%=LEN(Temp$)
  41.     MID$(InputMask$,Position%+1,X%)=Temp$
  42.     MID$(InputMask$,Position%,1)=KeyValue$:Position%=Position%+1
  43.     IFPosition%>Length%Position%=Position%-1
  44.   ENDIF
  45.  
  46. XELSE         'Handle special keys
  47.  
  48.               'Terminate input, return Result$ and move up one line
  49.               'for another input with UP arrow
  50.   IFCode$=CHR$(72)YOrigin%=YOrigin%-1:Result$=InputMask$:GOTO"NewLine"
  51.  
  52.               'Terminate input, return Result$ and move up down line
  53.               'for another input with DOWN arrow
  54.   IFCode$=CHR$(80)YOrigin%=YOrigin%+1:Result$=InputMask$:GOTO"NewLine"
  55.  
  56.               'HOME key to go to beginning of input line
  57.   IFCode$=CHR$(71)Position%=1
  58.  
  59.               'END key to go to end of input line
  60.   IFCode$=CHR$(79)Position%=Length%
  61.  
  62.               'Move cursor left with LEFT ARROW key
  63.   IFCode$=CHR$(75)Position%=Position%-1:IFPosition%=0Position%=1
  64.  
  65.               'Move cursor right with RIGHT ARROW key
  66.   IFCode$=CHR$(77)Position%=Position%+1:IFPosition%>Length%Position%=Length%
  67.  
  68.               'DELETE key to delete character and shift remaining characters
  69.               'left one position, padding end of input line with Mask$
  70.   LONGIFCode$=CHR$(83)
  71.     Temp$=RIGHT$(InputMask$,Length%-Position%)+Mask$
  72.     MID$(InputMask$,Position%,Length%-Position%)=Temp$
  73.   ENDIF
  74.  
  75.               'Toggle state of INSERT key
  76.   LONGIFCode$=CHR$(82)
  77.     IFInsert%=6THENInsert%=1ELSEInsert%=6
  78.   ENDIF
  79.  
  80. ENDIF
  81.  
  82.               'Display edited input line
  83. PRINT@(XOrigin%,YOrigin%)LEFT$(InputMask$,Length%);
  84.  
  85. GOTO"CheckKey"
  86.  
  87.               'Initialize new input line
  88. "NewLine"
  89. Length%=40:InputMask$=STRING$(Length%,32):Position%=1:GOTO"CheckKey"
  90.